package com.cvmars.jianyou.module.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.cvmars.jianyou.R;
import com.cvmars.jianyou.model.UserModel;
import com.cvmars.jianyou.ui.CircleImageView;
import com.cvmars.jianyou.utils.ImageUtils;
import com.cvmars.jianyou.utils.UtilHelper;

import java.util.List;

/**
 * Created by hehaifeng on 2018/12/22.
 */

public class JinengAdapter extends BaseQuickAdapter<UserModel, BaseViewHolder> {

    Context mContext;

    public JinengAdapter(Context context, int layoutResId, @Nullable List<UserModel> data) {
        super(layoutResId, data);
        mContext = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, final UserModel item) {


        TextView txtGuanzhu = helper.getView(R.id.txt_guanzhu);
        txtGuanzhu.setText(item.address_home);
//        if (item.relation_status == 2) {
//
//            txtGuanzhu.setText("互相关注");
//        } else if (item.relation_status == 1) {
//
//            txtGuanzhu.setText("已关注");
//
//        } else if (item.relation_status == -1) {
//
//            txtGuanzhu.setText("关注");
//        }

        helper.setText(R.id.txt_name, item.name)
        .setText(R.id.txt_intros,item.skills)
        .setText(R.id.txt_time, UtilHelper.forumFriendlyTime(item.last_request_at));

        TextView view = helper.getView(R.id.txt_intro);

        if (view != null) {
            view.setText(item.intro);
        }

        CircleImageView image = helper.getView(R.id.iv_avator);
        ImageView sex = helper.getView(R.id.iv_sex);

        if (item.gender == 1) {

            sex.setImageResource(R.drawable.ic_male);
        } else {

            sex.setImageResource(R.drawable.ic_women);
        }

        ImageUtils.loadImage(mContext, item.avatar_url, image);

    }
}
